<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>构造函数的模式</title>
  </head>

  <body>

  </body>
  <script>
    /*  
            构造函数 的 作用
                1. 简化 创建对象的 过程
                2. 区分不同类型的对象
        */

    function Person(name, age, gender, height, weigth) {
      this.name = name
      this.age = age
      this.gender = gender
      this.height = height
      this.weight = weigth
      this.sayHi = function () {}
    }


    function Dog(name, age, gender, height, weigth) {
      this.name = name
      this.age = age
      this.gender = gender
      this.height = height
      this.weight = weigth
      this.sayHi = function () {}
    }

    let p1 = new Person('狗蛋', 16, '男', 160, '80kg')

    let d1 = new Dog('旺财', 3, '公', 100, '30kg')
    console.log(p1);
    console.log(d1);
  </script>

</html>